<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h1>我是父级页面</h1>
  <iframe id="frame" src="http://127.0.0.1:5500/document.domain/child.html" frameborder="0"></iframe>

  <script>
    document.domain = "127.0.0.1";

    document.getElementById("frame").onload = function () {
      console.log(this.contentWindow.data);

    };

  </script>
</body>

</html>